package org.example.entity;

import org.springframework.data.mongodb.core.mapping.Document;

import java.util.Objects;

@Document("apiKey")
public class ApiKey {
	private String key;
	private Integer userId;
	private String id;

	public void setKey(String key) {
		this.key = key;
	}

	public ApiKey(String id, String key, Integer userId) {
		this.id = id;
		this.key = key;
		this.userId = userId;
	}

	public ApiKey() {
	}

	@Override
	public String toString() {
		return "ApiKey{" +
				"id='" + id + '\'' +
				", apiKey='" + key + '\'' +
				", userId=" + userId +
				'}';
	}

	@Override
	public boolean equals(Object o) {

		if (this == o) {
			return true;
		}
		if (o == null || getClass() != o.getClass()) {
			return false;
		}
		ApiKey apiKey1 = (ApiKey) o;
		return Objects.equals(id, apiKey1.id) && Objects.equals(key, apiKey1.key) && Objects.equals(userId, apiKey1.userId);
	}

	@Override
	public int hashCode() {
		return Objects.hash(id, key, userId);
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getKey() {
		return key;
	}

	public Integer getUserId() {
		return userId;
	}

	public void setUserId(Integer userId) {
		this.userId = userId;
	}
}
